/*
 * Copyright (c) 2021. ZSDP Inc. All rights reserved.
 */
package com.yff.bpmx.system.feign;

import com.yff.bpmx.common.core.constant.SecurityConstants;
import com.yff.bpmx.common.core.constant.ServiceNameConstants;
import com.yff.bpmx.common.core.domain.R;
import com.yff.bpmx.common.core.domain.SysForm;
import com.yff.bpmx.common.core.domain.SysRole;
import com.yff.bpmx.common.core.domain.SysUser;
import com.yff.bpmx.common.core.model.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Feign接口类
 *
 * @author zsdp
 */
@FeignClient(
        value = ServiceNameConstants.SYSTEM_SERVICE,
        fallback = ISysClientFallback.class
)
public interface ISysClient {
    String API_PREFIX = "/client";

    String USER = API_PREFIX + "/user";
    String USER_INFO = USER + "/info";
    String USER_REGISTER = USER + "/register";
    String USER_LIST = USER + "/list";
    String ROLE = API_PREFIX + "/role";
    String ROLE_INFO = ROLE + "/info";
    String ROLE_LIST = ROLE + "/list";
    String DEPLOY_FORM = API_PREFIX + "/deploy-form";
    String DEPLOY_FORM_INFO = DEPLOY_FORM + "/info";

    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source   请求来源
     * @return 结果
     */
    @GetMapping(USER_INFO + "/{username}")
    public R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source  请求来源
     * @return 结果
     */
    @PostMapping(USER_REGISTER)
    public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询用户
     *
     * @param id
     * @return
     */
    @PostMapping(USER_INFO)
    R<SysUser> selectUserById(@RequestParam("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询用户列表
     *
     * @param sysUser
     * @return
     */
    @PostMapping(USER_LIST)
    R<List<SysUser>> selectUserList(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询角色
     *
     * @param id
     * @return
     */
    @PostMapping(ROLE_INFO)
    R<SysRole> selectRoleById(@RequestParam("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询角色列表
     *
     * @param source
     * @return
     */
    @PostMapping(ROLE_LIST)
    R<List<SysRole>> selectRoleAll(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 查询表单信息
     *
     * @param id
     * @return
     */
    @PostMapping(DEPLOY_FORM_INFO)
    R<SysForm> selectSysDeployFormByDeployId(@RequestParam("id") String id);
}
